Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'Profile' page to TypeScript #34974

Merged
merged 17 commits into from
Mar 11, 2024

Conversation

pasyukevich
Copy link
Contributor

@pasyukevich pasyukevich commented Jan 23, 2024

Details

Fixed Issues

$ #25199
PROPOSAL:

Tests

  1. Go to a report (Chat)
  2. click on the avatar of any user
  3. Verify that the Profile Screen appears to the right and all options are normal
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Go to a report (Chat)
  2. click on the avatar of any user
  3. Verify that the Profile Screen appears to the right and all options are normal
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android-native-converted.webm
Android: mWeb Chrome
android-web-converted.webm
iOS: Native
ios-native-converted.mp4
iOS: mWeb Safari
ios-web-converted.mp4
MacOS: Chrome / Safari
desktop-web-converted.mov
MacOS: Desktop
desktop-native-converted.mov

src/pages/ProfilePage.tsx Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
Comment on lines +115 to +116
const notificationPreference = shouldShowNotificationPreference
? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}` as TranslationPaths)
: '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion can be escaped if we narrow down the type of notificationPreference reusing condition from shouldShowNotificationPreference const, like

Suggested change
const notificationPreference = shouldShowNotificationPreference
? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}` as TranslationPaths)
: '';
const notificationPreference = shouldShowNotificationPreference && report.notificationPreference && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN
? translate(`notificationPreferencesPage.notificationPreferences.${report.notificationPreference}`)
: '';

But I'm not sure if it's a better approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current is better cause we have a better visualisation of the logic

Comment on lines +33 to +34
import * as PersonalDetailsActions from '@userActions/PersonalDetails';
import * as ReportActions from '@userActions/Report';
import * as SessionActions from '@userActions/Session';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's turn this imports back as they was, and update OnyxTypes import to be
import type * as OnyxTypes from '@src/types/onyx';
This way we can use them like OnyxTypes.PersonalDetails, OnyxTypes.Report, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to import only the needed types

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasyukevich I agree with @VickyStash comment in this case, by doing your way you had to change the other imports to avoid conflicts, we don't need that if we use OnyxTypes.* pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me using ReportActions is way better, since we will see that we are dealing with the actions (not with class/ type)

src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
@pasyukevich
Copy link
Contributor Author

On hold till this PR is merged

@pasyukevich pasyukevich force-pushed the feature/migrate-Profile branch 3 times, most recently from 8e680a9 to ed0e882 Compare February 2, 2024 17:27
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
@pasyukevich pasyukevich force-pushed the feature/migrate-Profile branch from ed0e882 to 769d6d4 Compare February 9, 2024 18:15
Comment on lines +33 to +34
import * as PersonalDetailsActions from '@userActions/PersonalDetails';
import * as ReportActions from '@userActions/Report';
import * as SessionActions from '@userActions/Session';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasyukevich I agree with @VickyStash comment in this case, by doing your way you had to change the other imports to avoid conflicts, we don't need that if we use OnyxTypes.* pattern

src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@blazejkustra blazejkustra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one nitpick

src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
@pasyukevich pasyukevich marked this pull request as ready for review February 21, 2024 16:36
@pasyukevich pasyukevich requested a review from a team as a code owner February 21, 2024 16:36
@melvin-bot melvin-bot bot requested review from DylanDylann and removed request for a team February 21, 2024 16:36
Copy link

melvin-bot bot commented Feb 21, 2024

@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

import * as Report from '@userActions/Report';
import * as Session from '@userActions/Session';
import * as PersonalDetailsActions from '@userActions/PersonalDetails';
import * as ReportActions from '@userActions/Report';
Copy link
Contributor

@DylanDylann DylanDylann Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit confused. Because we also have '@userActions/ReportActions' import in some other places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using a Report is even more confusing since it does not describe what it is (especially when we are using the ts and have types)

src/pages/ProfilePage.tsx Show resolved Hide resolved
const login = lodashGet(details, 'login', '');
const timezone = lodashGet(details, 'timezone', {});
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const avatar = details?.avatar || UserUtils.getDefaultAvatar();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use ?? instead of ||

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use ||, since we can have an empty string, and in this case, we need to show the default avatar

const avatar = details?.avatar || UserUtils.getDefaultAvatar();
const fallbackIcon = details?.fallbackIcon ?? '';
const login = details?.login ?? '';
const timezone = details?.timezone;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a fallback value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so since we have some statements in code that rely on timezone undefined / empty value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasyukevich We pass the timezone to AutoUpdateTime Component as an Object. If timezone is undefined, we will get the error "can't read the attribute of undefined"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann It is not a problem, since we will render AutoUpdateTime only if shouldShowLocalTime is true that s already checks that the timezone is not empty

Copy link
Contributor

@DylanDylann DylanDylann Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasyukevich Also please help to resolve conflict. This PR has been delayed for a long time. Let's move forward

const reportID = ReportUtils.getChatByParticipants([accountID])?.reportID ?? '';

if ((Boolean(session) && Number(session?.accountID) === accountID) || SessionActions.isAnonymousUser() || !reportID) {
return `${ONYXKEYS.COLLECTION.REPORT}0`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return ${ONYXKEYS.COLLECTION.REPORT}0; will return undefined. Why do we need to update from return null;
to

return `${ONYXKEYS.COLLECTION.REPORT}0`;` will return undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key should be always a key according to our types

The key was updated from null to string, the actual result didn't changed

Before - OnyxStorage[null] - undefined
Now - OnyxStorage[${ONYXKEYS.COLLECTION.REPORT}0] - undefined


const shouldShowNotificationPreference = !_.isEmpty(props.report) && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : '';
const shouldShowNotificationPreference = !isEmptyObject(report) && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report could be null/undefined. Even though we have checked !isEmptyObject(report) I think we still should update to report?.notificationPreference for safer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will read report.notificationPreference only in the case when the object is not empty

!isEmptyObject(report) will guarantee that we are dealing with an object

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp this is NAB

@DylanDylann
Copy link
Contributor

@pasyukevich Bump on this one

@DylanDylann
Copy link
Contributor

@pasyukevich One more comment here and also resolve conflict

@DylanDylann
Copy link
Contributor

DylanDylann commented Feb 29, 2024

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Screen.Recording.2024-02-29.at.22.14.08.mov
Android: mWeb Chrome
Screen.Recording.2024-02-29.at.22.08.46.mov
iOS: Native
Screen.Recording.2024-02-29.at.21.22.56.mov
iOS: mWeb Safari
Screen.Recording.2024-02-29.at.21.27.12.mov
MacOS: Chrome / Safari
Screen.Recording.2024-02-29.at.21.25.28.mov
MacOS: Desktop
Screen.Recording.2024-02-29.at.21.27.56.mov

@DylanDylann
Copy link
Contributor

@pasyukevich Please merge main

@youssef-lr
Copy link
Contributor

youssef-lr commented Mar 4, 2024

Problem was solved with this Expensify/react-native-onyx#482

PR is merged and it bumped Onyx version, so TS should be fixed once we merge main here.

@youssef-lr
Copy link
Contributor

Looks like it's still failing...@fabioh8010 do you think we might have not fixed it fully or we missed a case? error in this PR is:

Error: src/pages/ProfilePage.tsx(257,5): error TS2322: Type '{ key: "report_"; selector: (report: OnyxEntry<{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined...' is not assignable to type 'OnyxPropMapping<ProfilePageProps, ProfilePageOnyxProps, "reports"> | OnyxPropCollectionMapping<ProfilePageProps, ProfilePageOnyxProps, "reports">'.
  Types of property 'selector' are incompatible.
    Type '(report: OnyxEntry<Report>) => OnyxEntry<Report>' is not assignable to type 'Selector<`report_${string}`, ProfilePageOnyxProps, OnyxCollection<{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "self...'.
      Type '(report: OnyxEntry<Report>) => OnyxEntry<Report>' is not assignable to type 'Selector<`report_${string}`, ProfilePageOnyxProps, OnyxCollection<{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "self...'.
        Type 'OnyxEntry<{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?: Rec...' is not assignable to type 'OnyxCollection<{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?...'.
          Type '{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?: Record<...> |...' is not assignable to type 'OnyxCollection<{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?...'.
            Type '{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?: Record<...> |...' is not assignable to type 'Record<string, ({ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields...'.
              Property 'chatType' is incompatible with index signature.
                Type 'ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }>' is not assignable to type '({ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?: Record<...> ...'.
                  Type 'string' is not assignable to type '{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?: Record<...> |...'.
                    Type 'string' is not assignable to type '{ chatType?: ValueOf<{ readonly POLICY_ANNOUNCE: "policyAnnounce"; readonly POLICY_ADMINS: "policyAdmins"; readonly DOMAIN_ALL: "domainAll"; readonly POLICY_ROOM: "policyRoom"; readonly POLICY_EXPENSE_CHAT: "policyExpenseChat"; readonly SELF_DM: "selfDM"; }> | undefined; ... 66 more ...; reportFields?: Record<...> |...'.

return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`;
},
export default withOnyx<ProfilePageProps, ProfilePageOnyxProps>({
reports: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasyukevich We improved the selector types but we still have a small issue in this case, that we must specify a selector that returns a non-nullable object (otherwise the types starts failing again), to fix chatReportSelector, change it to this:

const chatReportSelector = (report: OnyxEntry<Report>): Report =>
    (report && {
        reportID: report.reportID,
        participantAccountIDs: report.participantAccountIDs,
        parentReportID: report.parentReportID,
        parentReportActionID: report.parentReportActionID,
        type: report.type,
        chatType: report.chatType,
        isPolicyExpenseChat: report.isPolicyExpenseChat,
    }) as Report;

cc @youssef-lr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, many thanks @fabioh8010!

@pasyukevich pasyukevich force-pushed the feature/migrate-Profile branch from b8020cf to e4d4408 Compare March 6, 2024 10:19
@pasyukevich pasyukevich force-pushed the feature/migrate-Profile branch from e4d4408 to b7f8dae Compare March 6, 2024 10:50
@pasyukevich
Copy link
Contributor Author

@DylanDylann PR updated

Copy link
Contributor

@DylanDylann DylanDylann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

melvin-bot bot commented Mar 6, 2024

We did not find an internal engineer to review this PR, trying to assign a random engineer to #25199 as well as to this PR... Please reach out for help on Slack if no one gets assigned!

@melvin-bot melvin-bot bot requested a review from MonilBhavsar March 6, 2024 11:46
wrapperStyle={styles.breakAll}
shouldShowRightIcon
brickRoadIndicator={Report.hasErrorInPrivateNotes(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
brickRoadIndicator={ReportActions.hasErrorInPrivateNotes(report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fall back to empty string?
Prop definition:

/** The type of brick road indicator to show. */
brickRoadIndicator: PropTypes.oneOf([CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR, CONST.BRICK_ROAD_INDICATOR_STATUS.INFO, ''])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, with TS updates we can have one of the CONST.BRICK_ROAD_INDICATOR_STATUS values or undefined

src/pages/ProfilePage.tsx Outdated Show resolved Hide resolved
@DylanDylann
Copy link
Contributor

@pasyukevich There are some minor comments. Let's address it

@MonilBhavsar
Copy link
Contributor

@pasyukevich there is conflict to resolve

@pasyukevich
Copy link
Contributor Author

@MonilBhavsar Updated

Copy link
Contributor

@MonilBhavsar MonilBhavsar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MonilBhavsar MonilBhavsar merged commit 60a86c9 into Expensify:main Mar 11, 2024
15 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.50-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅


const shouldShowNotificationPreference = !_.isEmpty(props.report) && !isCurrentUser && props.report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const notificationPreference = shouldShowNotificationPreference ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : '';
const shouldShowNotificationPreference = !isEmptyObject(report) && !isCurrentUser && report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might have caused #39677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants